/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
function getXMLHTTP()
{
    //alert("in getXMLHTTP()");

    var xmlHttpRequest = null;
    try
    {
        xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");

    }
    catch(e)
    {
        try
        {
            xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(oc)
        {
            xmlHttpRequest = null;
        }
    }

    if(!xmlHttpRequest && typeof XMLHttpRequest != "undefined")
    {
        xmlHttpRequest = new XMLHttpRequest();
    }

    return xmlHttpRequest;
}

function login()
{
    var logonID = document.getElementById("logonID");
    var password = document.getElementById("password");

    if(logonID.value.length == 0)
    {
        alert("Please enter logonID!");
        logonID.focus();
        return false;
    }
    if(password.value.length == 0)
    {
        alert("Please enter password!");
        password.focus();
        return false;
    }
    return true;
}


function validateCreateUser()
{
    var fName = document.getElementById("fName");
    var lName = document.getElementById("lName");
    var email = document.getElementById("email");
    var loginID = document.getElementById("loginID");
    var password = document.getElementById("password");

    if(fName.value.length == 0)
    {
        alert("Please enter first name!");
        fName.focus();
        return false;
    }
    if(lName.value.length == 0)
    {
        alert("Please enter last name!");
        lName.focus();
        return false;
    }
    if(email.value.length == 0)
    {
        alert("Please enter email!");
        email.focus();
        return false;
    }
    if ((email.value).length > 0 && !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email.value)))
    {
        alert("Invalid E-mail Address! Please re-enter.")
        email.focus();
        return false;

    }
    if(loginID.value.length == 0)
    {
        alert("Please enter logonid!");
        loginID.focus();
        return false;
    }
    if(password.value.length == 0)
    {
        alert("Please enter password!");
        password.focus();
        return false;
    }

    return true;
}

function deleteUser(id)
{
    var result=confirm("Are you sure you want to delete this user!");
    if(result)
    {
        location.href = "/adminAction.do?method=deleteUser&id="+id;
    }
}

function validateCategory()
{
    var cName = document.getElementById("cName");
        if(cName.value.length == 0)
    {
        alert("Please enter category name!");
        cName.focus();
        return false;
    }
}

function deleteCategory(id)
{
    var result=confirm("Are you sure you want to delete this category!");
    if(result)
    {
        location.href = "/adminAction.do?method=deleteCategory&id="+id;
    }
}